<template>
	<!-- <step-nav style="margin-bottom: 0.1rem" justify="center" :active="stepNav.active" :colSize="12" :step-data="stepNav.stepData"></step-nav> -->
	<div class="ppm-container" style="height: 100vh">
		<!-- 收藏模板 -->
		<!-- <collect-tmpl></collect-tmpl> -->
		<!-- 订单项信息 -->
		<!-- <orderitem-info v-if="pageData.length > 0" :formData="formData" :infors="orderItemInfors"></orderitem-info> -->
		<PPMPage v-if="pageData.length > 0" :formData="formData" :pageData="pageData" @on-sumbit="testGet" @func="getParam" />
	</div>
</template>

<script>
import "@/crm3.0part7-ppm/styles/index.css";
import http from "@/utils/http";
import ppmmixin from "@/mixins/ppmmixin.js";
import prodSave from "@/utils/my";
import OrderService from "@/api/order/OrderService.js";
// import StepNav from "@/components/public/StepNav";
import { mapState } from "vuex";
export default {
	name: "orderEntryPPM",
	mixins: [ppmmixin],
	data() {
		return {
			orderItemInfors: {
				custSoNumber: "",
				custId: "",
				custName: "",
				accepteRegionId: "",
				commonRegionId: "",
				createStaff: "",
				createOrgId: "",
				productId: this.$route.params.prodId,
				attrId: "",
			},
			activeName: "first",
			radio1: "上海",

			productId: this.$route.params.prodId,
			resultDate: "",
			options: {
				onSubmit: (formData) => {
					this.testGet(formData);
				},
			},
			rule: [],
			res: {
				agentList: [],
				result: [],
				custOrderId: "23344", //客户订单ID 第一次保存的时候没有可以不传 报文
				custSoNumber: "JT12334455666", //流水号 第一次保存的时候没有可以不传
				operType: "1000", //操作类型 必传，1000新增，1200变更（单号必传），1300保持不变（单号必传，其余字段需要修改的传入）
				custOrderType: "50200001", //必填 客户订单类型 默认值：50200001
				orderSourceId: "10000", //订单受理运营商  默认值：10000
				createStaff: "17636", //创建人  缓存里面取staffId
				createOrgId: "1944664", //创建组织标识   缓存取 orgId
				accepteRegionId: "", //受理区域标识  默认：空
				accepteLanId: "", //受理本地网标识    默认：空
				custId: "2480012", //客户id   客户定位页面带会
				sysSource: "1000", //来源系统，原extSystem  默认：1000
				channelId: "渠道", //渠道的业务编码  待确定
				orderSource: "1000", //订单来源	普通受理，集团主数据EVT-C-0001  默认：1000
				bussDesc: "", //业务描述  默认：空
				remark: "", //备注 ORDER_COMMENT，是否替换  默认：空
				contactId: "", //合同id 保存项目是会更新  默认：空
				contactCd: "", //合同cd 保存项目是会更新 默认：空
				contactName: "", //合同名称  默认：空
				contactNumberType: "", //默认：空
				projectId: "", //项目id 默认：空
				projectName: "", //项目名称 默认：空
				projectManage: "", //保存项目经理id 默认：空
				saleId: "", //商机id 默认：空
				extCustOrderId: "", //外部客户订单标识 默认：空
			},
		};
	},
	created() {
		this.orderItemInfors.createStaff = this.user.staffId; //创建人  缓存里面取staffId
		this.orderItemInfors.createOrgId = this.user.orgId; //创建人  缓存里面取staffId
		this.orderItemInfors.accepteRegionId = this.user.regionId; //受理区域标识  默认：空
		this.orderItemInfors.custId = this.orderPosInfo.custId; //客户id   客户定位页面带回
		this.orderItemInfors.custName = this.orderPosInfo.custName; //客户名   客户定位页面带回
		// this.orderItemInfors.custSoNumber = this.$route.query.customerOrder ? this.$route.query.customerOrder.custSoNumber : ""; //页面初始化流水号
		this.orderItemInfors.custSoNumber = "13309090090"; //页面初始化流水号
	},
	computed: {
		...mapState("orders", ["stepNav"]),
		...mapState("orders", ["orderPosInfo"]),
		...mapState("user", ["user", "busiManagerId", "custManagerId"]),
	},
	// components: { StepNav },
	methods: {
		async testGet(params) {
			
			let result = await http({
				url: `/ppm/postT`,
				data: params,
				method: "POST",
			});
			this.resultDate = result;
		},

		getParam(data) {
			// // 
			
			// let arr = [];
			// arr.push(data);
			// //先根据产品id把对象处理成数组，数组里的对象个数对应就是产品的个数
			// arr.forEach((item) => {
			// 	this.res.result.push(Object.values(item));
			// });
			// 
		},

		Save() {
			this.saveProd();
		},
		//报文数据拼接结束
		preview() {
			let params = prodSave.buildObject(this.res, this.res.agentList);
			this.$alert(params, {
				dangerouslyUseHTMLString: true,
			});
		},

		// 报文提交
		async saveProd() {
			let params = prodSave.buildObject(this.res, this.res.agentList);
			
			const result = await OrderService.getOrderList(params);
			
			// if (result.status == -1) {
			//   this.openDialog("添加失败", result.data, "error");
			//   return;
			// }
			// this.openDialog("添加成功", "", "success");
			// this.$emit("addContactResult", result);
		},
	},
};
</script>

<style></style>
